{extend name="layout/index" /}

{block name="search"}
<div class="tile-title">
	<div class="tile-body">
		<form class="row" action="" >
			<div class="form-group col-md-3">
				<input class="form-control" type="text" name="title" placeholder="请输入名称" 
				value="{:input('get.title')}">
			</div>
			<div class="form-group col-md-9 align-self-end">
				<button class="btn btn-primary" type="submit">
					<i class="fa fa-fw fa-lg fa-search"></i>
					搜索
				</button>
				<a href="{:url($now_route['url'])}" class="btn btn-primary" >
					<i class="fa fa-fw fa-lg fa-dot-circle-o"></i>
					重置
				</a>
				<a href="{:url($now_route['controller'].'/excel',$getparam)}" target="_blank" class="btn btn-primary" >
					<i class="fa fa-fw fa-lg fa-download"></i>
					导出当前数据
				</a>
				{if checkurl($now_route["controller"]."/delete")}
				<button class="btn btn-primary alldelete" type="button">
					<i class="fa fa-fw fa-lg fa-trash-o"></i>
					删除
				</button>
				{/if}
			</div>
		</form>
	</div>
</div>
{/block}

{block name="table"}

<form id="delform">
	<table class="table">
		<thead>
			<tr>
				<th>
					<input type="checkbox" name="checkboxul" value="1" class="checkboxul">
				</th>

				<th>{$tables["fields"]["id"]["name"]}</th>

				<th>{$tables["fields"]["classs_id"]["name"]}</th>

				<th>{$tables["fields"]["title"]["name"]}</th>

				<th>{$tables["fields"]["url"]["name"]}</th>

				<th>{$tables["fields"]["target"]["name"]}</th>

				<th>{$tables["fields"]["images"]["name"]}</th>

				<th>{$tables["fields"]["status"]["name"]}</th>

				<th>{$tables["fields"]["recommend"]["name"]}</th>

				<th>{$tables["fields"]["topping"]["name"]}</th>

				<th>{$tables["fields"]["sort_time"]["name"]}</th>

				<th>{$tables["fields"]["create_time"]["name"]}</th>

				<th>{$tables["fields"]["update_time"]["name"]}</th>

				<th>操作</th>
			</tr>
		</thead>
		<tbody>

		{foreach $lists as $key=>$vo } 
		<tr>
			<td>
				<input type="checkbox" name="id[]" value="{$vo.id}" class="checkboxli">
			</td>

			<td>{$vo["id"]}</td>

			<td>
				{$vo["classs"]["name"]}
			</td>

			<td>{$vo["title"]}</td>

			<td>{$vo["url"]}</td>

			<td>{$vo["target"]}</td>

			<td><img src="{$vo["images"]}" width="100"></td>

			<td>{$vo["status"]}</td>

			<td>{$vo["recommend"]}</td>

			<td>{$vo["topping"]}</td>

			<td>{$vo["sort_time"]}</td>

			<td>{$vo["create_time"]}</td>

			<td>{$vo["update_time"]}</td>

			<td >
				{if checkurl($now_route["controller"]."/read")}
				<a href="{:url("read",array("id"=>$vo["id"]))}" title="浏览"><i class="fa fa-lg fa-fw fa-eye"></i></a>
				{/if}
				{if checkurl($now_route["controller"]."/edit")}
				<a href="{:url("edit",array("id"=>$vo["id"]))}" title="修改"><i class="fa fa-lg fa-fw fa-edit"></i></a>
				<a href="javascript:;" title="复制活动" data-href="{:url('copy',array('id'=>$vo['id']))}" class="copy">
					<i class="fa fa-lg fa-fw fa-copy"></i>
				</a>
				{/if}
				{if checkurl($now_route["controller"]."/delete")}
				<a href="javascript:;" data-href="{:url("delete",array("id"=>$vo["id"]))}" title="删除" class="delete">
					<i class="fa fa-lg fa-fw fa-trash-o"></i>
				</a>
				{/if}
			</td>
		</tr>
		{/foreach}
		<tr>
			<td colspan="14">
				{if checkurl($now_route["controller"]."/delete")}
				<button class="btn btn-primary alldelete" type="button">
					删除
				</button>
				{/if}
			</td>
		</tr>

		</tbody>
	</table>
</form>

{/block}

{block name="javascript"}
<script>
$('.delete').click(function(){
		var url = $(this).attr('data-href');
		var param = {};
		postdelete(url,param);
		});

$('.checkboxul').click(function(){
		//alert($(".checkboxul").is(':checked'));
		//alert($(".checkboxul").is(':checked'));
		var check = $(".checkboxul").is(':checked');
		if(check){
		$('.checkboxli').prop("checked",true);
		}else{
		$('.checkboxli').prop("checked",false);
		}
		});

$('.alldelete').click(function(){
		var url = '{:url('delete')}';
		var param = $("#delform").serialize();
		postdelete(url,param);
		});

$('.copy').click(function(){
	var url = $(this).attr('data-href');
	var param = {};
	confirmpost(url,param,"","确认复制该消息吗？");
});
</script>
{/block}
